<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"  
		xmlns:h="http://java.sun.com/jsf/html"  
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:a4j="http://richfaces.org/a4j">  
    
    <ui:composition template="#{helperNavigation.getPathTemplate('administration')}">
        <ui:define name="pageTitle">Gestion des livres</ui:define>
        <ui:define name="mainTitle">Gestion des livres</ui:define>
        <ui:define name="mainContent">
            
            <h:form id="formBooksAdmin">
                <rich:dataTable value="#{bookManager.loadAdminBooks()}" var="book" id="bookDataTable" rows="25" style="width: 100%;" styleClass="center myPanelGrid">
                    <rich:column>
                        <f:facet name="header" style="width: 5%;">ID</f:facet>
                        <h:outputText value="#{book.id}" />
                    </rich:column>
                    <rich:column style="text-align: left;">
                        <f:facet name="header">Titre</f:facet>
                        <h:outputText value="&lt;i class=icon-book>&lt;/i>&nbsp;#{book.title}" escape="false" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Auteur(s)</f:facet>
                        <h:outputText value="#{bookManager.getBookAuthors(book, '&lt;br />&lt;i class=icon-user>&lt;/i>&nbsp;', true, true)}" escape="false" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Prix</f:facet>
                        <h:outputText value="#{book.price} €" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Stock</f:facet>
                        <h:outputText value="#{book.stock}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Editeur</f:facet>
                        <h:outputText value="#{book.editor}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">Date</f:facet>
                        <h:outputText value="#{book.publicationDate}"><f:convertDateTime pattern="dd/MM/YYY" /></h:outputText>
                    </rich:column>
                    <rich:column>
                        <h:commandButton value="Modifier" action="#{bookManager.editBookForm(book)}" styleClass="btn btn-primary center"/>
                    </rich:column>
                    <rich:column>
                        <h:commandButton value="Supprimer" action="#{bookManager.removeBook(book)}" styleClass="btn btn-warning red center" onclick="return confirm('Souhaitez-vous vraiment supprimer ce livre ?');" />
                    </rich:column>
                    <f:facet name="footer">
                        <rich:column>
                            <h:commandButton value="Ajouter un livre" action="#{bookManager.createBookForm()}" styleClass="btn btn-success" />
                        </rich:column>
                    </f:facet>
                </rich:dataTable>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

